package com.example.rbacmanage.controller.background;

import com.example.rbacmanage.common.Result;
import com.example.rbacmanage.entity.app.ShopQrCode;
import com.example.rbacmanage.service.app.ShopQrCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/background/shopqrcode")
public class ShopQrCodeController {
    @Autowired
    private ShopQrCodeService shopQrCodeService;

    @GetMapping("/page")
    public Result page(ShopQrCode shopQrCode){
        return Result.success(shopQrCodeService.getPage(shopQrCode));
    }

    @GetMapping("/{id}")
    public Result info(@PathVariable Long id){
        return Result.success(shopQrCodeService.getById(id));
    }

    @PostMapping("/add")
    @PreAuthorize("hasAnyAuthority('background:shopqrcode:add')")
    public Result add(@RequestBody ShopQrCode shopQrCode){
        shopQrCodeService.save(shopQrCode);
        return Result.success();
    }
    @PostMapping("/update")
    @PreAuthorize("hasAnyAuthority('background:shopqrcode:update')")
    public Result update(@RequestBody ShopQrCode shopQrCode){
        shopQrCodeService.update(shopQrCode);
        return Result.success();
    }

    @DeleteMapping("/remove")
    @PreAuthorize("hasAnyAuthority('background:shopqrcode:remove')")
    public Result remove(@RequestBody Long[] ids){
        shopQrCodeService.remove(ids);
        return Result.success();
    }
}
